package com.time.admin.infra.basic.service.impl;

import com.time.admin.infra.basic.entity.PostMetric;
import com.time.admin.infra.basic.mapper.PostMetricDao;
import com.time.admin.infra.basic.service.PostMetricService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 文章交互数据统计表(PostMetrics)表服务实现类
 *
 * @author HuangQi
 * @since 2025-09-30 16:56:26
 */
@Service("postMetricService")
public class PostMetricServiceImpl implements PostMetricService {

    @Autowired
    private PostMetricDao postMetricsDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PostMetric queryById(Long id) {
        return this.postMetricsDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param postMetric 筛选条件
     * @return 查询结果
     */
    @Override
    public List<PostMetric> queryByCondition(PostMetric postMetric) {
        return this.postMetricsDao.queryAllByLimit(postMetric);
    }

    /**
     * 新增数据
     *
     * @param postMetric 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(PostMetric postMetric) {
        return this.postMetricsDao.insert(postMetric);
    }

    /**
     * 修改数据
     *
     * @param postMetric 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(PostMetric postMetric) {
        return this.postMetricsDao.update(postMetric);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.postMetricsDao.deleteById(id) > 0;
    }

    @Override
    public Integer deleteByPostId(Long postId) {
        return this.postMetricsDao.deleteByPostId(postId);
    }
}
